package com.example.myviewgroup;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * author: ts
 * created on: 2021/8/28 下午5:44
 * description:
 */
public class MyUtil {

    public static int getViewWidth(View view) {
        view.measure(0, 0);
        return view.getMeasuredWidth();
    }

    /**
     * 移除父布局中的子布局
     *
     * @param view
     */
    public static void removeFromParent(View view) {
        if (view.getParent() != null) {
            ((ViewGroup) view.getParent()).removeView(view);
        }
    }

}
